package com.mo.design.pattern.creational.factory;

import java.util.HashMap;
import java.util.Map;

public class NewInstanceFactory {
    private Map<String, Vehicle> registeredProducts = new HashMap<String, Vehicle>();

    public void registerVehicle(String vehicleId, Vehicle vehicle) {
        registeredProducts.put(vehicleId, vehicle);
    }

    public Vehicle createVehicle(String vehicle) {
        return registeredProducts.get(vehicle);
    }

    public static void main(String[] args) {
        Vehicle car = new Car();
        NewInstanceFactory newInstanceFactory = new NewInstanceFactory();
        newInstanceFactory.registerVehicle("car", car);
        Vehicle car1 = newInstanceFactory.createVehicle("car");
        System.out.println(car1.getClass());
    }
}
